<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta name="HandheldFriendly" content="True">
    <link rel="shortcut icon" href="<?php echo urldecode(Url::urlFormat("@favicon.ico"));?>"/>
    <link rel="bookmark" href="<?php echo urldecode(Url::urlFormat("@favicon.ico"));?>" />
<link href="<?php echo urldecode(Url::urlFormat("#css/bootstrap.css"));?>" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="<?php echo urldecode(Url::urlFormat("#css/common.css"));?>">
    <link rel="stylesheet" type="text/css" href="<?php echo urldecode(Url::urlFormat("#css/font-awesome.min.css"));?>">
    <link rel="stylesheet" type="text/css" href="<?php echo urldecode(Url::urlFormat("#js/artdialog/tiny-dialog.css"));?>">
 <link rel="stylesheet" type="text/css" href="<?php echo urldecode(Url::urlFormat("@static/css/font_icon.css"));?>" />
<link href="<?php echo urldecode(Url::urlFormat("#css/city-picker.css"));?>" rel="stylesheet">
<link href="<?php echo urldecode(Url::urlFormat("#css/main.css"));?>" rel="stylesheet">
   <style type="text/css">
        .swiper-container {width: 100%;}
        .js-template{display:none !important;}
    </style>
    <script src="<?php echo urldecode(Url::urlFormat("#js/jquery.min.js"));?>"></script>
    <script src="<?php echo urldecode(Url::urlFormat("#js/artdialog/dialog-plus-min.js"));?>"></script>
    <script src="<?php echo urldecode(Url::urlFormat("#js/common.js"));?>"></script>
    <script src="<?php echo urldecode(Url::urlFormat("#js/tinyslider.js"));?>"></script>
    <!-- <script src="<?php echo urldecode(Url::urlFormat("#js/bootstrap.js"));?>"></script> -->
    <script src="<?php echo urldecode(Url::urlFormat("#js/city-picker.data.js"));?>"></script>
    <script src="<?php echo urldecode(Url::urlFormat("#js/city-picker.js"));?>"></script>
    <script src="<?php echo urldecode(Url::urlFormat("#js/main.js"));?>"></script>
    <script type="text/javascript">
        var server_url = '<?php echo urldecode(Url::urlFormat("@"));?>__con__/__act__';
        var Tiny = {user:{name:'<?php echo isset($user['name'])?$user['name']:'';?>',id:'<?php echo isset($user['id'])?$user['id']:0;?>',online:<?php echo isset($user['id']) && $user['id']?'true':'false';?>}};
    </script>
    <title><?php if(isset($seo_title) && isset($site_title) && ($seo_title == $site_title)){?><?php echo isset($seo_title)?$seo_title:"";?><?php }else{?><?php echo isset($seo_title)?$seo_title:"";?>-<?php echo isset($site_title)?$site_title:"";?><?php }?></title>
</head>

<body>
    <!-- S 头部区域 -->
    <div id="header">
        <div class="topbar">
            <div class="layout-2 container">
                <div class="sub-1">
                    <!--
<div class="docs-methods">
    <form class="form-inline">
        <div id="distpicker">
            <div class="form-group">
                <div style="position: relative;">
                    <input id="city-picker3" class="form-control" readonly type="text" value="" data-toggle="city-picker">
                </div>
            </div>
        </div>
    </form>
</div>
                    -->
                </div>
                <div class="sub-2">
                    <ul class="nav-x">
                        <!-- 
                        <li class="item down">
                            <a href="<?php echo urldecode(Url::urlFormat("/ucenter"));?>">会员中心<i class="fa">&#xf107;</i></a>
                            <div class="dropdown user-box">
                                <?php $sidebar_nav = array('我的订单'=>'order', '我的关注'=>'attention', '商品咨询'=>'consult', '商品评价'=>'review', '我的消息'=>'message', '收货地址'=>'address', '我的优惠券'=>'voucher', '账户金额'=>'account');?>
                                <ul class="user-center">
                                    <?php foreach($sidebar_nav as $key => $item){?>
                                    <li class="link"><a href="<?php echo urldecode(Url::urlFormat("/ucenter/$item"));?>"><?php echo isset($key)?$key:"";?></a></li>
                                    <?php }?>
                                </ul>
                            </div>
                        </li>
                        <li class="item split"></li>
                        <li class="item down"><a href="">APP下载</a>
                            <div class="dropdown">
                                <img src="">
                            </div>
                        </li>
                        <li class="item split"></li>
                        <li class="item"><a href="<?php echo urldecode(Url::urlFormat("/ucenter/order"));?>">我的订单</a></li>
                        -->
                        <li class="item split"></li>
                        <?php if($user){?>
                        <li class="item"><?php if(isset($user['name'])){?>你好:<a href="<?php echo urldecode(Url::urlFormat("/ucenter/index"));?>"><?php echo isset($user['name'])?$user['name']:"";?></a>
                        进入 <a href="<?php echo urldecode(Url::urlFormat("/ucenter/index"));?>" style="color:red;">个人中心</a>
                         - <?php }?><a href="<?php echo urldecode(Url::urlFormat("/simple/logout"));?>">安全退出</a></li>
                        <?php }else{?>
                        <li class="item">
                            <a class="normal" href="<?php echo urldecode(Url::urlFormat("/simple/login"));?>">登录</a>
                            <!--/<a class="normal" href="<?php echo urldecode(Url::urlFormat("/simple/reg"));?>">注册</a>-->
                        </li>
                        <?php }?>
                        <li class="item"><a target="_blank" class="normal" href="<?php echo urldecode(Url::urlFormat("/simple/cart"));?>">购物车</a></li>
                    </ul>
                </div>
                
            </div>
        </div>
        <div class="container head-main">
            <!-- <div class="sub-1 logo"></div> -->
            <div class="sub-1">
            <a href="<?php echo urldecode(Url::urlFormat("/index/index"));?>"><img src="<?php echo urldecode(Url::urlFormat("@$site_logo"));?>" style="margin-top:20px;"></a></div>
            <div class="sub-2">
                <form id="search-form" class="search-form" action="<?php echo urldecode(Url::urlFormat("/"));?>" method="get">
                    <input type="hidden" name="con" value="index">
                    <input type="hidden" name="act" value="search">
                    <input type='hidden' name='tiny_token_' value='<?php echo Tiny::app()->getToken("");?>'/>
                    <input class="search-keyword" id="search-keyword" class="txt-keyword" name="keyword" value="" type="text">
                    <button class="btn-search ">搜索</button>
					<!-- 
                    <p id="tags-list"><?php $item=null; $query = new Query("tags");$query->order = "is_hot desc,sort desc,num desc";$query->limit = "3";$items = $query->find(); foreach($items as $key => $item){?><a href="#"><?php echo isset($item['name'])?$item['name']:"";?></a><?php }?></p>
                    -->
                </form>
            </div>
            <!-- 
            <div class="sub-3">
                <div class="shopping" id="shopping-cart"><i class="icon-cart-32"></i>购物车
                    <div class="dropdown">
                        <ul class="cart-box " id="cart-list">
                            <?php $total=0.00;?><?php if($cart){?><?php foreach($cart as $key => $item){?> <?php $total += $item['amount'];?>
                            <li class="cart-item" id="<?php echo isset($item['id'])?$item['id']:"";?>">
                                <div class="pic">
                                    <a class="card-pic" href="<?php echo urldecode(Url::urlFormat("/index/product/id/$item[goods_id]"));?>" target="_blank" title="<?php echo isset($item['name'])?$item['name']:"";?>"><img src="<?php echo urldecode(Url::urlFormat("@$item[img]"));?>" width="50" height="50"></a>
                                </div>
                                <div class="spec">
                                    <?php foreach($item['spec'] as $key => $spec){?>
                                    <p title="<?php echo isset($spec['name'])?$spec['name']:"";?>:<?php echo isset($spec['value'][2])?$spec['value'][2]:"";?>"><?php echo isset($spec['value'][2])?$spec['value'][2]:"";?></p>
                                    <?php }?>
                                </div>
                                <div class="num"><?php echo isset($item['num'])?$item['num']:"";?></div>
                                <div class="price" title="<?php echo isset($item['amount'])?$item['amount']:"";?>"><?php echo isset($item['amount'])?$item['amount']:"";?></div>
                                <a class="icon-close-16 ie6png" productid="<?php echo isset($item['id'])?$item['id']:"";?>"></a>
                            </li>
                            <?php }?>
                            <?php }else{?>
                            <li><div>购物车中还没有商品，赶紧选购吧！</div></li>
                            <?php }?>

                        </ul>
                        <div class="cart-count">
                            <span>合计：</span><span class="cart-total"><?php echo isset($total)?$total:"";?></span>
                            <a href="<?php echo urldecode(Url::urlFormat("/simple/cart"));?>" class="btn btn-main">去购物车结算</a>
                        </div>
                    </div>
                </div>
            </div>
            -->
        </div>
        <!-- S 导航栏 -->
        <div class="nav">
            <ul class="container">
                <li class="category-box">
                    <div class="link">
                    <a href="javascript:;" style="color: #fff;">全部分类<i class="triangle-b"></i></a>
                    </div>
                    <ul class="category">
                        <?php $current_category_ids='';$parent_category='';?>
                        <?php foreach($category as $key => $categ){?>
                        <li><a href="<?php echo urldecode(Url::urlFormat("/index/category/cid/$categ[id]"));?>">
                            <?php if(isset($categ['id'])){?>
                            <?php $current_category_ids=$categ['id'].',';$parent_category=$categ['id'];?>
                            <?php }?> <?php echo isset($categ['title'])?$categ['title']:"";?><i class="fa">&#xf105;</i></a>
                            <div class="category-sub">
                                <ul class="sub">
                                    <?php foreach($categ['child'] as $key => $child){?>
                                    <li>
                                        <h5><a href="<?php echo urldecode(Url::urlFormat("/index/category/cid/$child[id]"));?>">
                                            <?php if(isset($child['id'])){?>
                                            <?php $current_category_ids.=$child['id'].',';?>
                                            <?php }?>
                                            <?php echo isset($child['title'])?$child['title']:"";?></a></h5>
                                            <p>
                                                <?php if(isset($child['child'])){?>
                                                <?php foreach($child['child'] as $key => $grandson){?>
                                                <a href="<?php echo urldecode(Url::urlFormat("/index/category/cid/$grandson[id]"));?>">
                                                    <?php if(isset($grandson['id'])){?>
                                                    <?php $current_category_ids.=$grandson['id'].',';?><?php }?>
                                                    <?php echo isset($grandson['title'])?$grandson['title']:"";?></a>
                                                    <?php }?>
                                                    <?php }?>
                                                </p>
                                            </li>
                                            <?php }?>
                                        </ul>
                                    </div>
                                </li>
                                <?php }?>
                            </ul>
                        </li>
                        <li class="link"><a href="<?php echo urldecode(Url::urlFormat("/index/index/flag/0"));?>">首页</a></li>

                        <li class="link"><a href="<?php echo urldecode(Url::urlFormat("/index/index/condition_g_s/point/flag/1"));?>">购物积分专区</a></li>
                        <li class="link"><a href="<?php echo urldecode(Url::urlFormat("/index/index/flag/2"));?>">重消积分专区</a></li>

                        <?php $item=null; $query = new Query("nav");$query->where = "type = 'main' and enable = 1";$query->order = "`sort` desc";$items = $query->find(); foreach($items as $key => $item){?>
                        <li class="link"><a href="<?php if(strstr($item['link'],'http://')===false){?><?php echo urldecode(Url::urlFormat("$item[link]"));?><?php }else{?><?php echo isset($item['link'])?$item['link']:"";?><?php }?>" target="<?php if($item['open_type']==1){?>_blank<?php }else{?>_self<?php }?>"><?php echo isset($item['name'])?$item['name']:"";?></a></li>
                        <?php }?>
                    </ul>
                </div>
                <!-- E 导航栏 -->
            </div>
            <!-- E 头部区域 -->
            <!-- S 主控区域 -->
            <div id="main">
               <link type="text/css" rel="stylesheet" href="<?php echo urldecode(Url::urlFormat("#css/ucenter.css"));?>" />
<?php echo JS::import('form');?>
<?php echo JS::import('editor');?>
<?php echo JS::import('dialog?skin=tinysimple');?>
<?php echo JS::import('dialogtools');?>
<script>
    var editor;
    KindEditor.ready(function(K) {
      editor = K.create('textarea[name="content"],textarea[name="sale_protection"]', {
        uploadJson : '<?php echo urldecode(Url::urlFormat("/ucenter/upload_image"));?>'
      });
    });
</script>
<div class="container clearfix">
	<div id='widget_sub_navs'><?php $widget = Widget::createWidget('sub_navs');$widget->action = "ucsidebar";$widget->sidebar = $sidebar;$widget->act = $actionId;$widget->cache = "false";$widget->run();?></div>
	<div class="uc-content clearfix">
		<h1 class="title"><span><?php echo isset($title)?$title:"";?></span></h1>
		<form action="<?php echo urldecode(Url::urlFormat("/ucenter/goods_save"));?>" class="simple" method="post" callback="check_tab_location" >
				<input type="hidden" name="u_dp_id" value="<?php echo isset($user[id])?$user[id]:"";?>">
				<input type="hidden" name="seller_id" value="<?php echo isset($user[id])?$user[id]:"";?>"/>
				<input type="hidden" name="is_online" value="2"/>
			<?php if(isset($id)){?>
				<input type="hidden" name="id" value="<?php echo isset($id)?$id:"";?>">
			<?php }?>
			<div class="tab">
				<ul class="tab-head">
					<li>基本信息<i></i></li>
					<li>描述信息<i></i></li>
					<li>SEO信息<i></i></li>
					<li>售后保障<i></i></li>
				</ul>
				<div class="tab-body">
					<!-- 基本信息 -->
					<table class="form">
						<tr>
							<td class="label">商品分类：</td>
							<td>
								<select name="category_id" id="category_id" pattern="[1-9]\d*" alt="选择分类">
									<option value="0">选择分类...</option>
									<?php $id=isset($id)?$id:0;?>
									<?php $query = new Query("goods_category");$query->order = "path";$items = $query->find();?>
									<?php $goods_category = Common::treeArray($items);?>
									<?php foreach($goods_category as $key => $item){?>
									<?php if(!isset($path) || strpos($item['path'],$path)===false){?>
									<?php $num = count(explode(',',$item['path']))-3;?>
									    <option value="<?php echo isset($item['id'])?$item['id']:"";?>"><?php if($num>0){?>├<?php }?><?php echo str_repeat('──',$num);?><?php echo isset($item['name'])?$item['name']:"";?></option>
									    <?php }?>
									<?php }?>
					            </select> <label></label>
							</td>
						</tr>
						<tr>
							<td class="label">商品类型：</td>
							<td>
								<select name="type_id" id="type_id">
									<option value="0">选择类型...</option>
									<?php $id=isset($id)?$id:0;?>
									<?php $item=null; $query = new Query("goods_type");$items = $query->find(); foreach($items as $key => $item){?>
									<option value="<?php echo isset($item['id'])?$item['id']:"";?>"><?php echo isset($item['name'])?$item['name']:"";?></option>
									<?php }?>
					            </select> <label></label>
							</td>
						</tr>
						<tr id="goods_attr" style="display:<?php if(isset($goods_obj[attrs]) && strlen($goods_obj[attrs]) > 6 ){?><?php }else{?>none<?php }?>" >
							<td class="label">商品属性：</td>
							<td>
							<!-- 属性 -->
							        <div id="attr_list">
							          <table class="default">
							            <colgroup>
							            <col width="100" />
							            <col />
							          </colgroup>
							          <?php if(isset($goods_obj[type_id]) && $goods_obj[type_id]){?>
							            <?php $query = new Query("goods_type");$query->where = "id = $goods_obj[type_id]";$items = $query->find();?>
							            <?php $_attrs = unserialize($items[0]['attr']); $attrs = unserialize($goods_obj[attrs]);?>
							            <?php if($_attrs){?>
							              <?php foreach($_attrs as $key => $item){?>
							          <tr>
							            <td class='tr'><?php echo isset($item['name'])?$item['name']:"";?></td>
							            <td>
							              <?php if($item['show_type']<= 2){?>
							                <select name="attr[<?php echo isset($item['id'])?$item['id']:"";?>]">
							                <?php foreach($item['values'] as $key => $value){?>
							                <option value="<?php echo isset($value['id'])?$value['id']:"";?>" <?php if(isset($attrs[$item['id']]) && $attrs[$item['id']]==$value['id']){?> selected="selected" <?php }?> ><?php echo isset($value['name'])?$value['name']:"";?></option>
							                <?php }?>
							              </select>
							              <?php }else{?>
							              <input name="attr[<?php echo isset($item['id'])?$item['id']:"";?>]" type="text" value="<?php echo isset($attrs[$item['id']])?$attrs[$item['id']]:"";?>" />
							              <?php }?>
							            </td>
							          </tr>
							          <?php }?>
							          <?php }?>
							        <?php }?>
							        </table>
							      </div>
						      <!-- 属性end -->
						      </td>
						</tr>
						<tr>
							<td class="label">商品品牌：</td>
							<td>
								<select name="brand_id">
									<option value="0">选择品牌...</option>
									<?php $item=null; $query = new Query("brand");$items = $query->find(); foreach($items as $key => $item){?>
									<option value="<?php echo isset($item['id'])?$item['id']:"";?>"><?php echo isset($item['name'])?$item['name']:"";?></option>
									<?php }?>
								</select> <label></label>								
							</td>
						</tr>
						<tr>
							<td class="label">商品名称：</td>
							<td>
								<input name="name" type="text" pattern="required" value="<?php echo isset($goods_obj[name])?$goods_obj[name]:"";?>" style="width:400px;" alt="不能为空"> <label></label>
							</td>
						</tr>
						<tr>
							<td class="label">商品副标题：</td>
							<td>
								<input name="subtitle" type="text"  value="<?php echo isset($goods_obj[subtitle])?$goods_obj[subtitle]:"";?>" style="width:400px;" > <label></label>
							</td>
						</tr>
						<tr>
							<td class="label">商品关键词：</td>
							<td>
								<input name="tag_ids" type="text"  value="<?php echo isset($goods_obj[tag_ids])?$goods_obj[tag_ids]:"";?>" style="width:400px;"> <label></label>
							</td>
						</tr>
						<tr>
							<td class="label">商品编号：</td>
							<td>
								<input name="goods_no" id="goods_no" type="text" pattern="\w{3,}" alt="请输入3个以上的字符(不能为中文)" value="<?php echo isset($goods_obj[goods_no])?$goods_obj[goods_no]:"";?>" > <label></label>
							</td>
						</tr>
						<tr><input type="hidden" value="0" name=""/>
							<td class="label"></td>
							<td>
							排序： <input class="small" name="sort" id="sort" type="text" pattern="int" empty="" value="<?php echo isset($goods_obj[sort])?$goods_obj[sort]:1;?>">&nbsp;&nbsp;
							计量单位：<input class="small" name="unit" pattern="required" type="text" value="<?php echo isset($goods_obj[unit])?$goods_obj[unit]:'件';?>">
							</td>
						</tr>
						<tr>
							<td class="label">产品相册：</td>
							<td>
								<button class="button  select_button" type="button" ><b class="icon-plus green"></b> 添加图片</button> <b class="red f12">(注：点选图片，使其成为默认图片)</b>
							</td>
						</tr>
						<tr>
							<td class="label"></td>
							<td>
								<div>
									<ul class="piclist" id="pic_list">
										<?php if(isset($goods_obj[imgs]) && $imgs =  unserialize($goods_obj[imgs])){?>
										<?php foreach($imgs as $key => $item){?>
											<li <?php if($item == $img){?> class="current" <?php }?>>
												<div class="bord">
													<input type="hidden" name="imgs[]" value="<?php echo isset($item)?$item:"";?>">
													<img src="<?php echo urldecode(Url::urlFormat("@$item"));?>" data-src=<?php echo isset($item)?$item:"";?> onclick="selectImg(this)" width="80" height="80" alt="">
												</div>
												<div class="opera">
													<a class="icon-arrow-left-2" href="javascript:;"></a>&nbsp;&nbsp;<a class="icon-arrow-right-2" href="javascript:;"></a>&nbsp;&nbsp;<a class="icon-close" href="javascript:;" onclick="delImg(this)"></a>
												</div>
											</li>
										<?php }?>
										<?php }?>
									</ul>
										<input name="img" type="text" style="visibility: hidden;width:0;" value="<?php echo isset($goods_obj[img])?$goods_obj[img]:"";?>" pattern="required" id="img_index" alt="添加商品图片"/>
									<label></label>
								</div>
							</td>
						</tr>
						<tr>
							<td class="tab_box4" colspan="2">商品规格</td>
						</tr>
						<tr>
							<td class="label" colspan="2">
								<div id="goods_list" >
						          <table class="default border">
						            <colgroup>
						            <col width="160"/>
						            <col/>
						          </colgroup>
						          <tr>
						            <td class="tr">
						              <b class="red">*</b>
						              货号：
						            </td>
						            <td>
						              <input  type="text" pattern="\w{3,}" name="pro_no" alt="请输入3个以上的字符(不能为中文)" value="<?php echo isset($goods_obj[goods_no])?$goods_obj[goods_no]:"";?>"/>
						              <label></label>
						            </td>
						          </tr>
						          <tr>
						            <td class="tr">
						              <b class="red">*</b>
						              库存：
						            </td>
						            <td>
						              <input class="small" pattern="int" type="text" name="store_nums" value="<?php echo isset($goods_obj[store_nums])?$goods_obj[store_nums]:"";?>" alt="必需为整数" />
						              <label></label>
						            </td>
						          </tr>
						          <tr>
						            <td class="tr">
						              <b class="red">*</b>
						              预警线：
						            </td>
						            <td>
						              <input class="small" type="text" pattern="int" name="warning_line" value="<?php echo isset($goods_obj[warning_line])?$goods_obj[warning_line]:2;?>" alt="必需为整数"/>
						              <label></label>
						            </td>
						          </tr>
						          <tr>
						            <td class="tr">
						              <b class="red">*</b>
						              重量(g)：
						            </td>
						            <td>
						              <input class="small" type="text" pattern="int" name="weight" value="<?php echo isset($goods_obj[weight])?$goods_obj[weight]:0;?>" alt="必需为整数"/>
						              <label></label>
						            </td>
						          </tr>
						          <tr>
						            <td class="tr">
						              <b class="red">*</b>
						              零售价：
						            </td>
						            <td>
						              <input class="small" type="text" pattern="float" name="sell_price" value="<?php echo isset($goods_obj[sell_price])?$goods_obj[sell_price]:"";?>" alt="整数或保留小数点后两位精确度的数" />
						              <label></label>
						            </td>
						          </tr>
						          <tr>
						            <td class="tr">
						              <b class="red">*</b>
						              市场价：
						            </td>
						            <td>
						              <input class="small" pattern="float" type="text" name="market_price" value="<?php echo isset($goods_obj[market_price])?$goods_obj[market_price]:"";?>" alt="整数或保留小数点后两位精确度的数"/>
						              <label></label>
						            </td>
						          </tr>
						          <tr>
						            <td class="tr">
						              <b class="red">*</b>
						              成本价：
						            </td>
						            <td>
						              <input class="small" pattern="float" type="text" name="cost_price" value="<?php echo isset($goods_obj[cost_price])?$goods_obj[cost_price]:0;?>" alt="整数或保留小数点后两位精确度的数"/>
						              <label></label>
						            </td>
						          </tr>
						          <tr>
						            <td class="tr">
						              <b class="red">*</b>
						              积分：
						            </td>
						            <td>
						              <input class="small" type="text" pattern="int" name="point" value="<?php echo isset($point)?$point:0;?>" alt="必须整数" />
						              <label></label>
						            </td>
						          </tr>
						          <tr>
						            <td class="tr">
						              <b class="red">*</b>
						              规格：
						            </td>
						            <td>
						              <button class="button " type="button" id="open_spec">
						                <b class="icon-plus green"></b>
						                开启规格
						              </button>
						            </td>
						          </tr>
						        </table>
						      </div>
						      <!-- 规格列表	 -->
							<div style="overflow: auto;" id="spec_list">

						        <?php if(isset($specs) && strlen($specs)>6){?>
						        <!--隐藏goods规格信息-->
						        <script type="text/javascript">
						          $("#goods_list").css({display:'none'});
						          $("#goods_list input").attr("disabled","disabled");
						        </script>
						        <?php  $specs = unserialize($specs); $spec_ids='';?>
						        <div style="margin:10px 0;"><button onclick="edit_spec()" type="button" class="button"><b class=" icon-pencil-2 green"></b> 编辑规格</button> <button id="close_spec_button" type="button" onclick="close_spec()" class="button"><b class="icon-close red"></b> 关闭规格</button></div><table class="default" style="width:auto"><tbody><tr><th>商品货号</th><?php foreach($specs as $key => $item){?><th><?php echo isset($item['name'])?$item['name']:"";?><?php $spec_ids .= $item['id'].',';?></th><?php }?><th><input name="spec_items" type="hidden" value="<?php echo rtrim($spec_ids,",");?>">库存</th><th>预警线</th><th>零售价</th><th>市场价</th><th>成本价</th><th>积分</th><th>重量(g)</th><th>操作</th></tr>
						        <?php $products_info=array();?>
						        <?php $item=null; $query = new Query("products");$query->where = "goods_id = $id";$query->order = "id";$items = $query->find(); foreach($items as $key => $item){?>
						        <?php $spec = unserialize($item['spec']);$spec_str = '';?>
						        <tr class="min_inputs"><td><input type="text" pattern="required" name="pro_no[]" value="<?php echo isset($item['pro_no'])?$item['pro_no']:"";?>" style="width:160px"></td><?php foreach($spec as $key => $spc){?><td><?php echo isset($spc['value'][2])?$spc['value'][2]:"";?><?php $spec_str .= implode(":",$spc['value']).",";?></td><?php }?><td><?php $spec_item_key = trim($spec_str,',');$products_info[$spec_item_key]=array('store_nums'=>$item['store_nums'],'warning_line'=>$item['warning_line'],'sell_price'=>$item['sell_price'],'k_point'=>$item['k_point'],'market_price'=>$item['market_price'],'cost_price'=>$item['cost_price'],'weight'=>$item['weight']);?><input name="spec_item[]" type="hidden" value="<?php echo trim($spec_str,',');?>"><input type="text" pattern="int" class="small" name="store_nums[]" value="<?php echo isset($item['store_nums'])?$item['store_nums']:"";?>"></td><td><input pattern="int" class="small" type="text" name="warning_line[]" value="<?php echo isset($item['warning_line'])?$item['warning_line']:"";?>"></td><td><input class="small" pattern="float" type="text" name="sell_price[]" value="<?php echo isset($item['sell_price'])?$item['sell_price']:"";?>"></td><td><input class="small" pattern="float" type="text" name="market_price[]" value="<?php echo isset($item['market_price'])?$item['market_price']:"";?>"></td><td><input pattern="float" class="small" type="text" name="cost_price[]" value="<?php echo isset($item['cost_price'])?$item['cost_price']:"";?>"></td><td><input class="small" pattern="int" type="text" name="k_point[]" value="<?php echo isset($item['k_point'])?$item['k_point']:"";?>"></td><td><input class="small" pattern="int" type="text" name="weight[]" value="<?php echo isset($item['weight'])?$item['weight']:"";?>"></td><td><a href="javascript:;" class="icon-close" onclick="spec_del(this)"></a></td></tr>
						        <?php }?>
						        </tbody></table>
						        <?php }?>

						      </div>
						      <!-- 规格列表end -->
							</td>
						</tr>

					</table>
					<!-- 基本信息end -->
					<!-- 描述信息 start -->
					<div>
					<div>
					  <textarea id="content" pattern="required" name="content" style="width:800px;height:560px;visibility:hidden;"><?php echo isset($goods_obj[content])?$goods_obj[content]:"";?></textarea>
					  <label></label>
					</div>
					</div>
					<!-- 描述信息 end -->	
					<table  class="form">
						<tr>
							<td class="lable">页面标题：</td>
							<td>
								<input name="seo_title" type="text" value="<?php echo isset($goods_obj[seo_title])?$goods_obj[seo_title]:"";?>"><label></label>
							</td>
						</tr>
						<tr>
							<td class="lable">页面关键词：</td>
							<td>
								<input name="seo_keywords" type="text" value="<?php echo isset($goods_obj[seo_keywords])?$goods_obj[seo_keywords]:"";?>"><label></label>
							</td>
						</tr>
						<tr>
							<td class="lable">页面描述：</td>
							<td>
								<input name="seo_description" type="text" value="<?php echo isset($goods_obj[seo_description])?$goods_obj[seo_description]:"";?>"><label></label>
							</td>
						</tr>
					</table>
					<!-- SEO 信息 end -->
				  <!-- 售后保障 start -->
				  <div>
				    <div>
				      <textarea id="sale_protection"  name="sale_protection" style="width:800px;height:560px;visibility:hidden;"><?php echo isset($goods_obj[sale_protection])?$goods_obj[sale_protection]:"";?></textarea><label></label>
				    </div>
				  </div>
				  <!-- 售后保障 end -->				
				</div>
			</div>
			<div style="text-align:center;margin-top:10px;">
			  <input type="submit" class="focus_button" value="提交" >
			  &nbsp;&nbsp;&nbsp;&nbsp;
			  <input type="reset" value="重置" class="button"></div>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">
var form =  new Form();
form.setValue('category_id','<?php echo isset($goods_obj[category_id])?$goods_obj[category_id]:"";?>');
form.setValue('type_id','<?php echo isset($goods_obj[type_id])?$goods_obj[type_id]:"";?>');
form.setValue('brand_id','<?php echo isset($goods_obj[brand_id])?$goods_obj[brand_id]:"";?>');
$("#type_id").change();


<?php if(isset($products_info)){?>
var products_info = <?php echo JSON::encode($products_info);?>;
<?php }else{?>
var products_info = new Array();
<?php }?>

$(".select_button").on("click",function(){
      uploadFile();
      return false;
    });
$("#goods_no").on("change",function(){
  var that = $(this);
  if(that.val()){
    var old_val = $("input[name='pro_no']").val();
    $("input[name='pro_no']").val(that.val());
    $("input[name='pro_no[]']").each(function(i){
      var current_value = $(this).val();
      var temp = old_val+'_'+(i+1);
      if(current_value=='' || current_value==temp) $(this).val(that.val()+'_'+(i+1));
    });
  }

})
function uploadFile(){
  art.dialog.open('<?php echo urldecode(Url::urlFormat("/ucenter/photoshop"));?>',{id:'upimg_dialog',lock:true,opacity:0.1,title:'选择图片',width:613,height:380});
}
function selectImg(id){
  var img = $(id).attr('data-src');
  $("#pic_list li").removeClass("current");
  $(id).parent().parent().addClass("current");
  $("#img_index").val(img);
}
//回写选择图片
function setImg(value){
  var show_src = "<?php echo urldecode(Url::urlFormat("@"));?>"+value;
  if(value.indexOf("http://")!=-1) show_src = value;

  if($("#pic_list img[src='"+show_src+"']").get(0)){
    art.dialog.alert("图片已经添加，请不要重复添加！");
  }else{
    $("#pic_list").append('<li> <div class="bord"><input type="hidden" name="imgs[]" value="'+value+'" /> <img src="'+show_src+'" data-src="'+value+'" onclick="selectImg(this)" width="80" height="80" alt=""></div> <div class="opera"><a class="icon-arrow-left-2" href="javascript:;" ></a>&nbsp;&nbsp;<a class="icon-arrow-right-2" href="javascript:;"></a>&nbsp;&nbsp;<a class="icon-close" href="javascript:;" onclick="delImg(this)"></a> </div> </li>');
      bindEvent();
      if($("#pic_list li.current").length <=0 ){
        $("#pic_list li:eq(0)").addClass("current");
        $("#img_index").val(value);
      }
      FireEvent(document.getElementById('img_index'),'change');
      art.dialog({id:'upimg_dialog'}).close();
  }

}
//删除添加的图片
function delImg(id){
  $(id).parent().parent().remove();
  if($("#pic_list li:eq(0)").length <= 0)$("#img_index").val('');
}
function linkImg(id){
  var src = $(id).parent().parent().find('img').attr('src');
  art.dialog({id:'linkDialog',title:'图片地址',content:'<div>图片地址：<input type="text" value='+src+' style="width:300px;"/></div>',width:420});
}

//开启规格
$("#open_spec").on("click",function(){
      edit_spec();
      return false;
    });

//添加规格


function addSpec(specs){
  specs = specs.split(";");
  var str_ths ='<tr><th>商品货号</th>';
  var spec_array = new Array();
  var spec_items = '';
  var num = 0;
  for(i in specs){
    var spec_str = specs[i].split("=");
    var spec = spec_str[0].split(":");
    var values = spec_str[1].split(",");
    var values_array = new Array();
    var index = 0;
    for(v in values){
      var value = values[v].split(':');
      //values_array[index++] = value[0]+":"+(value[2]==''?value[1]:value[2]);
      values_array[index++] = values[v];
    }
    spec_array[num++] = values_array;
    spec_items += spec[0]+',';
    str_ths += '<th>'+spec[1]+'</th>';
  }
  spec_items = spec_items.slice(0,-1);
  // spec_a =_spec_array;
  str_ths += '<th><input name="spec_items" type="hidden" value="'+spec_items+'"/>库存</th><th>预警线</th><th>零售价</th><th>市场价</th><th>成本价</th><th>积分</th><th>重量(g)</th><th>操作</th></tr>';

 var str_tds = '';
 // art.dialog.alert(spec_a);
 // specs = values_array();
 specs = descartes(spec_array);
 var pro_no_per = $("#goods_no").val();
 var store_nums = $("input[name='store_nums']").val();
 var warning_line = $("input[name='warning_line']").val();
 var sell_price = $("input[name='sell_price']").val();
 var k_point = $("input[name='k_point']").val();
 var market_price = $("input[name='market_price']").val();
 var cost_price = $("input[name='cost_price']").val();
 var weight = $("input[name='weight']").val();

  for(i in specs){
    var spec_item = '';
    str_tds += '<tr class="min_inputs"><td><input type="text" pattern="required" name="pro_no[]"  value="'+(pro_no_per==''?'':pro_no_per+'_'+(parseInt(i)+1))+'" style="width:160px"></td>';

    if(typeof specs[i] == "object"){
        for(j in specs[i]){
          spec_item += specs[i][j]+',';
          var value = specs[i][j].split(":");
        str_tds +='<td>'+(value[2]==''?value[1]:value[2])+'</td>';
      }
    }
    else{
      spec_item = specs[i]+',';
      var value = specs[i].split(":");
      str_tds +='<td>'+(value[2]==''?value[1]:value[2])+'</td>';
    }
    spec_item = spec_item.slice(0,-1);
    if(products_info!=undefined && products_info[spec_item]!=undefined){
      var s_item = products_info[spec_item];
      store_nums = s_item['store_nums']!=undefined?s_item['store_nums']:'';
      warning_line = s_item['warning_line']!=undefined?s_item['warning_line']:'';
      sell_price = s_item['sell_price']!=undefined?s_item['sell_price']:'';
      k_point = s_item['k_point']!=undefined?s_item['k_point']:'';
      market_price = s_item['market_price']!=undefined?s_item['market_price']:'';
      cost_price = s_item['cost_price']!=undefined?s_item['cost_price']:'';
      weight = s_item['weight']!=undefined?s_item['weight']:'';

    }
    str_tds += '<td><input name="spec_item[]" type="hidden" value="'+spec_item+'"/><input type="text" pattern="int" class="small" name="store_nums[]" value="'+store_nums+'"></td><td><input  pattern="int" class="small" type="text" name="warning_line[]" value="'+warning_line+'"></td><td><input class="small" pattern="float" type="text" name="sell_price[]" value="'+sell_price+'"></td><td><input class="small" pattern="float" type="text" name="market_price[]" value="'+market_price+'"></td><td><input pattern="float" class="small" type="text" name="cost_price[]" value="'+cost_price+'"></td><td><input class="small" pattern="float" type="text" name="k_point[]" value="'+k_point+'"></td><td><input class="small" pattern="int" type="text" name="weight[]" value="'+weight+'"></td><td><a href="javascript:;" class="icon-close" onclick="spec_del(this)" ></a></td></tr>';
  }
  $("#spec_list").css({display:''});

  $("#spec_list").html('<div style="margin:10px 0;"><button onclick="edit_spec()" type="button" class="button"><b class=" icon-pencil-2 green"></b> 编辑规格</button> <button id="close_spec_button" onclick="close_spec()" class="button" type="button"><b class="icon-close red"></b> 关闭规格</button></div><table class="default" style="width:auto">'+str_ths+str_tds+'</table>');
  $("#goods_list").css({display:'none'});
  $("#goods_list input").attr("disabled","disabled");
  art.dialog({id:'spec_list'}).hide();
  $("#spec_list input").on("change",function(){
    changeProductsInfo($(this));
    // var parent = $(this).parent().parent();
    // var spec_item = $("input[name='spec_item[]']",parent).val();
    // var name = $(this).attr("name");
    // var value = $(this).val();
    // name = name.replace("[]",'');
    // if(products_info[spec_item]==undefined) products_info[spec_item] = new Array();
    // products_info[spec_item][name] = value;
  });
}
$("#spec_list input").on("change",function(){
  changeProductsInfo($(this));
});

function changeProductsInfo(el)
{
    var parent = el.parent().parent();
    var spec_item = $("input[name='spec_item[]']",parent).val();
    var name = el.attr("name");
    var value = el.val();
    name = name.replace("[]",'');
    if(products_info[spec_item]==undefined) products_info[spec_item] = new Array();
    products_info[spec_item][name] = value;
}
//关闭规格
function close_spec(){
  $("#spec_list").css({display:'none'});
  $("#spec_list input").attr("disabled","disabled");
  $("#goods_list input").removeAttr("disabled");
  $("#goods_list").css({display:''});
  return false;
}

function edit_spec(){
  var spec_dcr_str = '';
  $("input[name='spec_item[]']").each(function(){
    spec_dcr_str += $(this).val()+",";
  })
  art.dialog.data("spec_init_data",spec_dcr_str.slice(0,-1));
  if($("iframe[name='Openspec_list']").length>0)art.dialog({id:'spec_list'}).show();
  else{
    art.dialog.open('<?php echo urldecode(Url::urlFormat("/ucenter/show_spec_select"));?>',{id:'spec_list',resize:false,title:'商品规格',width:800,height:460});
  }
  return false;
}

//删除规格
function spec_del(id){
  if($("#spec_list tr").length>2) $(id).parent().parent().remove();
  else {
    art.dialog.confirm('你确认删除操作？', function(){
      close_spec();
    });
  }
}
//选择分类
$("#category_id").on("change",function(){
  $.post("<?php echo urldecode(Url::urlFormat("/ajax/category_type"));?>", {id: $(this).val()},function(data){
    form.setValue('type_id',data.type_id);
    $("#type_id").change();
  },"json");
})

//改变类型处理操作
$("#type_id").on("change",function(){
  $("#goods_attr").css({display:'none'});
  $("#attr_list table tr").remove();

  $.post("<?php echo urldecode(Url::urlFormat("/ajax/type_attr"));?>", {id: $(this).val()},function(data){
    if(data){
      $("#goods_attr").css({display:''});
      var tr = "";

      for(var i in data){
        tr += "<tr><td class='tr'>"+data[i].name+"：</td><td>";
        var values = data[i].values;
        if(data[i].show_type<=2){
          tr += '<select name="attr['+data[i].id+']">';
          for(var j in values){
            tr += '<option value="'+values[j].id+'">'+values[j].name+'</option>';
          }
          tr += '</select>';
        }
        else{
          tr += '<input type="text" pattern="required" name="attr['+data[i].id+']" />';
        }

        tr += "</td></tr>";
      }
      $("#attr_list table").append(tr);
    }

  },"json");
})

//操作左右按钮事件绑定
function bindEvent(){
  $(".icon-arrow-right-2").off();
  $(".icon-arrow-left-2").off();
  $(".icon-arrow-right-2").on("click",function(){
    var current_tr = $(this).parent().parent();
    current_tr.insertAfter(current_tr.next());
  });
    $(".icon-arrow-left-2").on("click",function(){
    var current_tr = $(this).parent().parent();
    if(current_tr.prev().html()!=null)current_tr.insertBefore(current_tr.prev());
  });

}
bindEvent();
</script>

           </div>
           <!-- E 主控区域 -->

           <!-- S 底部区域 -->
           
           <div id="footer">
            <div class="promise">
                <div class="clearfix container">
                    <dl>
                        <dt class="icon-1"></dt>
                        <dd>
                            <p class="title">诚信交易</p>
                            <p>所有产品均出正规渠道采购</p>
                        </dd>
                    </dl>
                    <dl>
                        <dt class="icon-2"></dt>
                        <dd>
                            <p class="title">60元包邮</p>
                            <p>全国各地，满60元快递包邮</p>
                        </dd>
                    </dl>
                    <dl>
                        <dt class="icon-3"></dt>
                        <dd>
                            <p class="title">极速更新</p>
                            <p>所有商品信息及时更新</p>
                        </dd>
                    </dl>
                    <dl>
                        <dt class="icon-4"></dt>
                        <dd>
                            <p class="title">7天退换货</p>
                            <p>会员享受7天无理由退换货</p>
                        </dd>
                    </dl>
                    <dl>
                        <dt class="icon-5"></dt>
                        <dd>
                            <p class="title">真实拍摄</p>
                            <p>100%真实拍摄，杜绝虚假</p>
                        </dd>
                    </dl>
                </div>
            </div>
            <div class="helps clearfix container">
                <?php $item=null; $query = new Query("help_category");$query->order = "sort desc";$query->limit = "5";$items = $query->find(); foreach($items as $key => $item){?>
                <dl >
                    <dt class="clearfix"><span class="icon-<?php echo isset($item['alias'])?$item['alias']:"";?> fl"></span><a href="javascript:;"><?php echo isset($item['name'])?$item['name']:"";?></a></dt>
                    <?php $help=null; $query = new Query("help");$query->where = "category_id = $item[id]";$query->item = "$help";$query->cache = "true";$query->cacheTime = "1200";$items = $query->find(); foreach($items as $key => $help){?>
                    <dd><a href="<?php echo urldecode(Url::urlFormat("/index/help/id/$help[id]"));?>"><?php echo isset($help['title'])?$help['title']:"";?></a></dd>
                    <?php }?>
                </dl>
                <?php }?>
                <div class="col-contact">
                    <p class="phone">0371-53625762
                    </p>
                    <p>周一至周日 8:00-18:00
                        <br>（仅收市话费）</p>
                        <a class="btn btn-main">24小时在线客服</a>
                    </div>
                </div>
                <div class="copyright">
                    <div class="container bootom">
                        <div class="sub-1">
                        	<!-- 
                            <div class="logo"></div>
                            -->
                        </div>
                        
                        <div class="sub-2">
                        	<!-- 
                            <div><?php $item=null; $query = new Query("nav");$query->where = "type = 'bottom'";$query->order = "`sort` desc";$items = $query->find(); foreach($items as $key => $item){?>
                                <a href="<?php if(strstr($item['link'],'http://')===false){?><?php echo urldecode(Url::urlFormat("$item[link]"));?><?php }else{?><?php echo isset($item['link'])?$item['link']:"";?><?php }?>" target="<?php if($item['open_type']==1){?>_blank<?php }else{?>_self<?php }?>"><?php echo isset($item['name'])?$item['name']:"";?></a>
                                <?php }?></div>
                                -->
                                <!-- 
                                <span>Powered by <a href="#"><b style="color: #e74503"><?php echo isset($site_title)?$site_title:"";?></b></a> © 201-</span></div>
                                -->
                                <div class="sub-3">
                                    <a target="_blank" href="#"><img src="<?php echo urldecode(Url::urlFormat("#images/v-logo-2.png"));?>" alt="诚信网站"></a>
                                    <a target="_blank" href="#"><img src="<?php echo urldecode(Url::urlFormat("#images/v-logo-1.png"));?>" alt="诚信网站"></a>
                                    <a target="_blank" href="#"><img src="<?php echo urldecode(Url::urlFormat("#images/v-logo-3.png"));?>" alt="网上交易保障中心"></a>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- E 底部区域 -->
                    <script>
                        $(".slider").Slider();
                        $(".category li").mouseenter(function() {
                            $(this).addClass("hover");
                        }).mouseleave(function() {
                            $(this).removeClass("hover");
                        });

                        $("#tags-list a").each(function(){
                            $(this).on("click",function(){
                                $("#search-keyword").val($(this).text());
                                $("#search-form").submit();
                            })
                        });
                        $(".category-box").mouseenter(function(){
                            $(this).addClass("on");
                        }).mouseleave(function(){
                            $(this).removeClass("on");
                        });

                        function updateCart(data){
                            var card_items = '';
                            for(var i in data){
                                var spec = data[i]['spec'];
                                var spec_str = '';
                                for(var k in spec){
                                    spec_str +="<p>"+spec[k]['value'][2]+"</p>";
                                }
                                card_items += '<div class="cart-item" id="'+i+'"><div class="pic"><img src="<?php echo urldecode(Url::urlFormat("@"));?>'+data[i]['img']+'" width="50" height="50"></div><div class="spec">'+spec_str+'</div><div class="num">'+data[i]['num']+'</div><div class="price">'+(data[i]['amount'])+'</div><a class="icon-close-16 ie6png" productid="'+data[i]['id']+'"></a></div>';
                            }
                            $("#cart-list").empty().append(card_items);
                            changeCartInfo();
                            bindDelEvent();
                        }
                        bindDelEvent();
                        function bindDelEvent(){
                            $("#shopping-cart .icon-close-16").on("click",function(){
                                var btn_close = $(this);
                                $.post("<?php echo urldecode(Url::urlFormat("/index/cart_del"));?>",{id:btn_close.attr("productid")},function(){
                                    btn_close.parent().remove();
                                    changeCartInfo();
                                    $("#card-wrap").css({top:1-$("#card-wrap").outerHeight()},"fast");
                                },"json");
                            });
                        }

                        function changeCartInfo(){
                            $(".cart-product-num").text($(".cart-item").size());
                            var total = 0.00;
                            $(".cart-item .price").each(function(){
                                total += parseFloat($(this).text());
                            });
                            $(".cart-total").text(total.toFixed(2));
                            if($(".cart-item").size()==0){
                                $("#cart-list").empty().append('<li><div>购物车中还没有商品，赶紧选购吧！</div></li>');
                            }
                        }
                        $("#tags-list a").each(function(){
                            $(this).on("click",function(){
                                $("#search-keyword").val($(this).text());
                                $("#search-form").submit();
                            })
                        });
                        
                        
                        
                        /**
                        *左侧菜单栏的关闭和打开
                        */
                        $(function(){
                        	/*
                        	$("div[class='box'] h2").toggle(function(){
                        		$(this).next("ul").hide('2000');
                        	},function(){
                        		$(this).next("ul").show('2000');
                        	});
                        	*/
                        	
                        	$("div[class='box'] h2").click(function(){
                        		//$(this).next("ul").hide('2000');
                        		var $ul = $(this).next("ul");
                        		if($ul.is(':visible'))
                        		{
                        			$ul.hide("2000");
                        		}
                        		else
                        		{
                        			$ul.show("2000");	
                        		}
                        		
                        	});
                        	
                        	
                        });
                        
                        
                    </script>
                </body>
                </html>

<!--Powered by TinyRise-->